<template>
  <div>
    <!--    <el-menu :default-openeds="opens" router>
          <el-menu-item index="/home">
            <i class="el-icon-s-home"></i>
            <span slot="title">主页</span>
          </el-menu-item>
    &lt;!&ndash;      <el-submenu index="2">
            <template slot="title"><i class="el-icon-menu"></i>系统管理</template>
            <el-menu-item-group>
              <el-menu-item index="/system/user">
                <i class="el-icon-user-solid"></i>
                <span slot="title">用户管理</span>
              </el-menu-item>
              <el-menu-item index="/system/role">
                <i class="el-icon-s-help"></i>
                <span slot="title">角色管理</span>
              </el-menu-item>
              <el-menu-item index="/system/menu">
                <i class="el-icon-s-goods"></i>
                <span slot="title">菜单管理</span>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title"><i class="el-icon-menu"></i>内容管理</template>
            <el-menu-item-group>
              <el-menu-item index="/content/category">
                <i class="el-icon-s-help"></i>
                <span slot="title">分类管理</span>
              </el-menu-item>
              <el-menu-item index="/content/product">
                <i class="el-icon-s-goods"></i>
                <span slot="title">商品管理</span>
              </el-menu-item>
              <el-menu-item index="/content/order">
                <i class="el-icon-s-order"></i>
                <span slot="title">订单管理</span>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>&ndash;&gt;

          <div v-for="item in menus"
               :key="item.id">
    &lt;!&ndash;        <div v-if="item.parentId === 0">
              <el-menu-item index="/">
                <template slot="title">
                  <i :class="item.icon"></i>
                  <span slot="title">{{item.menuName}}</span>
                </template>
              </el-menu-item>
            </div>&ndash;&gt;
            <div >
              <el-submenu :index="item.id + ''">
                <template slot="title">
                  <i :class="item.icon"></i>
                  <span slot="title">{{item.menuName}}</span>
                </template>

                <div v-for="subItem in item.children"
                     :key="subItem.id">
                  <el-menu-item :index="'/' + subItem.path">
                    <i :class="subItem.icon"></i>
                    <span slot="title">{{subItem.menuName}}</span>
                  </el-menu-item>
                </div>
              </el-submenu>
            </div>
          </div>
        </el-menu>-->

    <template v-for="item in treeData">
      <el-submenu
          :index="item.id + ''"
          :key="item.id"
          v-if="item.children && item.children.length > 0 && item.menuType === 'M'">
        <template slot="title">
          <i :class="item.icon"></i>
          <span slot="title">{{ item.menuName }}</span>
        </template>
        <admin-aside :tree-data="item.children"></admin-aside>
      </el-submenu>
      <el-menu-item
          v-else-if="item.menuType === 'C'"
          :index="item.path"
          :key="item.id">
        <i :class="item.icon"></i>
        <span slot="title">{{ item.menuName }}</span>
      </el-menu-item>
    </template>
  </div>
</template>

<script>
export default {
  name: 'admin-aside',
  props: {
    treeData: {
      type: Array,
      default: function () {
        return []
      }
    }
  },

  data() {
    return {
      // menus:
      opens: localStorage.getItem('menus')
          ? JSON.parse(localStorage.getItem('menus')).map((v) => v.id + '')
          : {},
    }
  },

  mounted() {
  },

  methods: {}
}
</script>

<style lang="scss" scoped>


.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}
</style>
